<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">

    <script src="/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
    <script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script src="/lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
<body>
    <div class="layui-btn-container">
        <button type="button" class="layui-btn layui-btn-normal" id="upload">选择文件</button><br />
        <button type="button" class="layui-btn" id="bindBtn" style="width:100%;">开始上传</button>
</div>
</body>
<script>
    layui.use(['layer', 'upload'], function () {
        var layer = layui.layer, upload = layui.upload;
        //执行实例
        upload.render({
            elem: '#upload', //绑定元素
            auto: false,//是否自动完成文件上传
            bindAction: '#bindBtn',
            url: "http://localhost:8080/informationRecord/import", //上传接口/你后台代码的接口路径
            accept: 'file', //允许上传文件的类型
            exts: 'xls|xlsx',//指定文件类型上传
            method: 'POST',
            done: function (res) {
                //上传完毕回调
                layer.msg(res.message);
            },
            error: function (e) {
                //请求异常回调
                console.log(e);
                layer.msg(e);
            }
        });
    });
</script>
</html>